package com.py.wemedia.controller.v1;

import com.py.model.common.dtos.ResponseResult;
import com.py.model.wemedia.dtos.SensitiveDto;
import com.py.model.wemedia.pojos.WmSensitive;
import com.py.wemedia.service.WmSensitiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/sensitive")
public class WmSensitiveController {

    @Autowired
    private WmSensitiveService wmSensitiveService;

    /**
     * 删除敏感词
     *
     * @param id
     * @return
     */
    @DeleteMapping("/del/{id}")

    public ResponseResult deleteSensitive(@PathVariable("id") Integer id) {
        return wmSensitiveService.deleteSensitive(id);
    }

    /**
     * 列表展示
     *
     * @param dto
     * @return
     */
    @PostMapping("/list")
    public ResponseResult listForSensitive(@RequestBody SensitiveDto dto) {
        return wmSensitiveService.listBySensitive(dto);
    }

    /**
     * 新增敏感词
     *
     * @param sensitive
     * @return
     */
    @PostMapping("/save")
    public ResponseResult saveSensitive(@RequestBody WmSensitive sensitive) {
        return wmSensitiveService.saveSensitive(sensitive);

    }

    /**
     * 修改敏感词
     * @param sensitive
     * @return
     */
    @PostMapping("/update")
    public ResponseResult updateSensitive(@RequestBody WmSensitive sensitive) {
        return wmSensitiveService.updateSensitive(sensitive);
    }

}
